<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<h:outputStylesheet library="css" name="style.css" />
	<title>SGC Web</title>
</h:head>
<h:body>
	<!-- 	<h:graphicImage url="/resources/images/Logo_small.jpg"></h:graphicImage> -->
	<h:panelGrid columns="3">
		<h:outputLabel styleClass="title" value="SGC Web" />
		<h:outputLabel styleClass="title" value="-" />
		<h:outputLabel styleClass="title"
			value="#{checkUserBean.usuario.company}" />
	</h:panelGrid>
	<h:panelGroup styleClass="alignmentRight">
		<h:panelGrid columns="2" columnsClasses="alignmentRight" border="0">
			<h:outputLabel value="Usuario:" />
			<h:outputText value="#{checkUserBean.usuario.descrip}" />
		</h:panelGrid>
	</h:panelGroup>
	<p:spacer height="10" />
	<h:form>
		<p:panel header="Aprobar Ordenes de Compra">
			<p:panel>
				<p:dataTable var="c"
					value="#{purchaseOrderAprBean.headers}" widgetVar="headerTable"
					emptyMessage="No se han seleccionado registros" paginator="true"
					rows="5"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15" id="headerTab">
					<p:column id="por_no" headerText="P.Or. Nro." sortBy="req_no">
						<h:outputText value="#{c.por_no}" />
					</p:column>
					<p:column id="fec_por" sortBy="fec_por" headerText="Fec. Sol.">
						<h:outputText value="#{c.fec_por}" />
					</p:column>
					<p:column id="fec_req" sortBy="fec_req" headerText="Fec. Req.">
						<h:outputText value="#{c.fec_req}" />
					</p:column>
					<p:column id="solicitante" sortBy="solicitante"
						headerText="Solicitante">
						<h:outputText value="#{c.solicitante_name}" />
					</p:column>
					<p:column id="suplier" sortBy="suplier" headerText="Proveedor">
						<h:outputText value="#{c.suplier_name}" />
					</p:column>
					<p:column id="Detalle" headerText="Detalle">
						<h:outputText value="#{c.por_deta}" />
					</p:column>
					<p:column>
						<p:commandButton id="selectButton" icon="ui-icon-tag"
							title="Visualizar" action="#{purchaseOrderAprBean.show()}"
							update=":j_idt18:pnldeta">
							<f:setPropertyActionListener value="#{c}"
								target="#{purchaseOrderAprBean.header}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>
			</p:panel>
			<p:spacer height="5" width="5" />
			<p:panel id="pnldeta">
				<h:panelGroup styleClass="alignmentLeft">
					<h:panelGrid columns="4" columnsClasses="alignmentLeft" border="0">
						<h:outputLabel value="Pedido:" />
						<h:inputText readonly="true"
							value="#{purchaseOrderAprBean.header.por_no}" />
						<h:outputLabel value="Status:" />
						<h:selectOneMenu value="#{purchaseOrderAprBean.header.status_name}">
							<f:selectItems value="#{statusBean.statusPorList}" />
						</h:selectOneMenu>

						<h:outputLabel value="Fecha de Solicitud: " />
						<h:inputText readonly="true"
							value="#{purchaseOrderAprBean.header.fec_por}" />
						<h:outputLabel value="Fecha Requerida: " />
						<h:inputText readonly="true"
							value="#{purchaseOrderAprBean.header.fec_req}" />
						<h:outputLabel value="Solicitante: " />
						<h:inputText readonly="true"
							value="#{purchaseOrderAprBean.header.solicitante_name}" />
						<h:outputLabel value="Proveedor: " />
						<h:inputText readonly="true"
							value="#{purchaseOrderAprBean.header.suplier_name}" />
						<h:outputLabel value="Centro de Costo: " />
						<h:inputText readonly="true"
							value="#{purchaseOrderAprBean.header.cecos_name}" />
						<h:outputLabel value="Detalle: " />
						<h:inputTextarea readonly="true" rows="4" cols="50"
							value="#{purchaseOrderAprBean.header.por_deta}" />
					</h:panelGrid>
				</h:panelGroup>
				<p:outputPanel id="positions">
					<p:dataTable id="posTable" value="#{purchaseOrderAprBean.positions}"
						var="pos">
						<p:column>
							<f:facet name="header">
								<h:outputText value="Material" />
							</f:facet>
							<h:outputText value="#{pos.mat_name}" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="Unidad" />
							</f:facet>
							<h:outputText value="#{pos.mat_unit}" />
						</p:column>
						<p:column>
							<f:facet name="header">
								<h:outputText value="Cant" />
							</f:facet>
							<h:outputText value="#{pos.mat_cant}" />
						</p:column>
					</p:dataTable>
				</p:outputPanel>

			</p:panel>
		</p:panel>
		<p:spacer height="50" width="5" />
					<p:splitButton value="Grabar"  update="headerTab msgs"
						actionListener="#{purchaseOrderAprBean.save}" icon="ui-icon-disk">
						<p:separator />
						<p:menuitem value="Inicio" url="navegacion.xhtml"
							icon="ui-icon-extlink" />
						<p:menuitem value="Salir" url="index.xhtml" icon=".ui-icon-power"
							actionListener="#{checkUserBean.logout}" />
					</p:splitButton>
		<h:panelGrid columns="1">
			<p:messages id="msgs" />
		</h:panelGrid>
	</h:form>
</h:body>
</html>